<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */

$baseURL = "{$_SERVER['PHP_SELF']}?newscode={$_GET['newscode']}";

$action = $_GET['action'];

if ($action == 'ViewAdd') {
	$new = true;
	$btnAction="addSave()";
	$heading = $lang_News_Add_Heading;
	$formAction = "{$baseURL}&action=Add";
	$disabled = '';
	$edit=false;
} else {
	$new = false;
	$btnAction="addUpdate()";
	$heading = $lang_News_Edit_Heading;
	$formAction = "{$baseURL}&action=Update";
	$disabled = "disabled='true'";
	$edit=false;
}
/*
$noOfEmployees = $records['noOfEmployees'];
$employeeSearchList = $records['employeeSearchList'];
$manager = $records['manager']; 
$jobTitles = $records['jobTitles'];

$vacancy = $records['vacancy'];
*/
$locRights=$_SESSION['localRights'];
$allowEdit = $locRights['edit'];
/*
if ($_SESSION['isAdmin'] ) {
    $locRights = array('add'=> true , 'edit'=> true , 'delete'=> true, 'view'=> true);
}else {
	$locRights = array('add'=> false , 'edit'=> false , 'delete'=> false, 'view'=> true);
}
*/
?>
<html>
<head>
<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="../../scripts/archive.js"></script>
<script type="text/javascript" src="../../scripts/octopus.js"></script>
<script>
	var editMode = <?php echo $new ? 'true' : 'false'; ?>;

	var employeeSearchList = new Array();
	
    function goBack() {
        location.href = "<?php echo $baseURL; ?>&action=List";
    }

	function validate() {
	/*
		err = false;
		msg = '<?php echo $lang_Error_PleaseCorrectTheFollowing; ?>\n\n';

		errors = new Array();
        if ($('cmbHiringManager').value == -1) {
			err = true;
			msg += "\t- <?php echo $lang_Recruit_JobVacancy_PleaseSpecifyHiringManager; ?>\n";
        }

        if ($('cmbJobTitle').value == -1) {
			err = true;
			msg += "\t- <?php echo $lang_Recruit_JobVacancy_PleaseSpecifyJobTitle; ?>\n";
        }

		if (err) {
			alert(msg);
			return false;
		} else {
			return true;
		}
		*/
		return true;
	}

    function save() {
    	/*
    	$('cmbHiringManager').value = '-1';
    	
    	for (i in employeeSearchList) {
    		if ($('txtHiringManagerSearch').value == employeeSearchList[i][0]) {
    			$('cmbHiringManager').value = employeeSearchList[i][2];
    			break;
    		}
    	}
		*/
		if (validate()) {
        	$('frmJobVacancy').submit();
		} else {
			return false;
		}
    }
	//Chinh nguyen add
	function returnEmpDetail(){
		var popup=window.open('../../templates/hrfunct/emppop.php?reqcode=REP&LEAVE=LEAVE','Employees','height=450,width=400');
        if(!popup.opener) popup.opener=self;
		popup.focus();
	}
	function reset() {
		$('frmJobVacancy').reset();
	}


	function mout() {
		if(editMode) {
			$('editBtn').src='../../themes/<?php echo $styleSheet;?>/pictures/btn_save.gif';
		} else {
			$('editBtn').src='../../themes/<?php echo $styleSheet;?>/pictures/btn_edit.gif';
		}
	}

	function mover() {
		if(editMode) {
			$('editBtn').src='../../themes/<?php echo $styleSheet;?>/pictures/btn_save_02.gif';
		} else {
			$('editBtn').src='../../themes/<?php echo $styleSheet;?>/pictures/btn_edit_02.gif';
		}
	}

	function edit()	{

<?php if($locRights['edit']) { ?>
		if (editMode) {
			save();
			return;
		}
		editMode = true;
		var frm = $('frmJobVacancy');
		<?php $edit =true; ?>
		for (var i=0; i < frm.elements.length; i++) {
			frm.elements[i].disabled = false;
		}
		$('editBtn').src="../../themes/<?php echo $styleSheet;?>/pictures/btn_save.gif";
		$('editBtn').title="<?php echo $lang_Common_Save; ?>";

<?php } else {?>
		alert('<?php echo $lang_Common_AccessDenied;?>');
<?php } ?>
	}
	
	function showAutoSuggestTip(obj) {
		if (obj.value == '<?php echo $lang_Common_TypeHereForHints; ?>') {
			obj.value = '';
			obj.style.color = '#000000';
		}
	}

</script>

    <link href="../../themes/<?php echo $styleSheet;?>/css/style.css" rel="stylesheet" type="text/css">
    <style type="text/css">@import url("../../themes/<?php echo $styleSheet;?>/css/style.css"); </style>

    <style type="text/css">
    <!--

	.items {
		border-top: none;
		border-left: solid 1px #999999;
		border-right: solid 1px #999999;
		border-bottom: solid 1px #999999;
		padding: 4px;
		display: none;
		width: 240px;
	}

    label,select,input,textarea {
        display: block;  /* block float the labels to left column, set a width */
        width: 150px;
        float: left;
        margin: 10px 0px 2px 0px; /* set top margin same as form input - textarea etc. elements */
    }
    input[type=checkbox] {
		width: 15px;
		background-color: transparent;
		vertical-align: bottom;
    }

    #active {
        width: 15px;
        height: 15px;
        background-color: transparent;
        vertical-align: bottom;
    }

    /* this is needed because otherwise, hidden fields break the alignment of the other fields */
    input[type=hidden] {
        display: none;
        border: none;
        background-color: red;
    }

    label {
        text-align: left;
        width: 110px;
        padding-left: 10px;
    }

    select,input,textarea {
        margin-left: 10px;
    }

    input,textarea {
        padding-left: 4px;
        padding-right: 4px;
    }

    textarea {
        width: 330px;
        height: 150px;
    }

    form {
        min-width: 550px;
        max-width: 800px;
    }

    br {
        clear: left;
    }

    .roundbox {
        margin-top: 10px;
        margin-left: 10px;
        width: 750px;
    }

    .roundbox_content {
        padding:10px;
    }

	.hidden {
		display: none;
	}

	.display-block {
		display: block;
	}

	#nohiringmanagers {
		font-style: italic;
		color: red;
        padding-left: 10px;
        width: 400px;
        border: 1px;
	}
	
	#employeeSearchAC {
 	    width:15em; /* set width here */
 	    padding-bottom:2em;
 	}
	
 	#employeeSearchAC {
 	    z-index:9000; /* z-index needed on top instance for ie & sf absolute inside relative issue */
 	}
 	.newsTitle {
		font-size: 12px;
		color: #005CA8;
		font-weight: bold;
		text-align: left;
		padding-left: 0px;
		padding-right: 0px;
		text-decoration: none;
		

	}
	.nd { font-size:12px; color:#666666; font-weight:normal;text-align: left;
		padding:0px 0px 0px 5px;font-family: arial, Verdana, tahoma;
		}
	.nd a {color: #666666; text-decoration: underline;}
	.nd a:hover {color:#FF3300; text-decoration: none}
	
	.nd_right { font-size:12px; color:#666666; font-weight:normal;
			padding:5px 6px 5px 12px;}
	.nd_right a {color: #666666; text-decoration: underline;}
	.nd_right a:hover {color:#FF3300; text-decoration: none}
	
	.nd_bold { font-size:12px; color:#666666; font-weight:bold;
		padding:0px 0px 0px 0px;}
	.nd_bold a {color: #666666; text-decoration: none;}
	.nd_bold a:hover {color:#FF3300; text-decoration: none}
	
 	#txtEmployeeSearch {
 	    _position:absolute; /* abs pos needed for ie quirks */
 	}
    -->
</style>
<?php include ROOT_PATH."/lib/common/autocomplete.php"; ?>



</head>
<body class="yui-skin-sam">
	<center>
	<div style="size: 100%">
  	<div id="navigation" style="margin:5;text-align: left" >
  		<img title="Back" onMouseOut="this.src='../../themes/<?php echo $styleSheet;?>/pictures/btn_back.gif';"
  			 onMouseOver="this.src='../../themes/<?php echo $styleSheet;?>/pictures/btn_back_02.gif';"
  			 src="../../themes/<?php echo $styleSheet;?>/pictures/btn_back.gif" onClick="goBack();">
	</div>
    <?php $message =  isset($_GET['message']) ? $_GET['message'] : null;
    	if (isset($message)) {
			$col_def = CommonFunctions::getCssClassForMessage($message);
			$message = "lang_Common_" . $message;
	?>
	<div class="message">
		<font class="<?php echo $col_def?>" size="-1" face="Verdana, Arial, Helvetica, sans-serif">
			<?php echo (isset($$message)) ? $$message: ""; ?>
		</font>
	</div>
	<?php }	?>
  <div align="justify">
  <form name="frmJobVacancy" id="frmJobVacancy" method="post" action="<?php echo $formAction;?>" onSubmit="return false;">
		<table width="100%">
		<tr>
			<td class="newstitle" width="100%" nowrap="nowrap">
				<span class="newsTitle"><?php echo $records['news_title']; ?></span>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<?php echo $records['news_date']; ?>
			</td>
		</tr>
		<tr>
			<td>
				<span class="nd"><?php echo $records['news_content']; ?></span>
			</td>
		</tr>		
		</table>
		
		<br/><br/>
		<?php	if($allowEdit) { ?>
        <div align="left">
        	<a href="<?php echo $baseURL . '&id='. $records['news_id'] ;?>&amp;action=Edit" class="listViewTdLinkS1">
            <img  id="editBtn" border="0"
            	onMouseOut="mout();" onMouseOver="mover();"
            	src="../../themes/<?php echo $styleSheet;?>/pictures/<?php echo $new ? 'btn_save.gif' : 'btn_edit.gif';?>"> </a>
			<img id="saveBtn" src="../../themes/<?php echo $styleSheet;?>/pictures/btn_clear.gif"
			onMouseOut="this.src='../../themes/<?php echo $styleSheet;?>/pictures/btn_clear.gif';"
			onMouseOver="this.src='../../themes/<?php echo $styleSheet;?>/pictures/btn_clear_02.gif';" onClick="reset();" >
        </div>
        <?php } ?>
	</form>
    </div>
    <br>
    <div id="navigation" style="margin:0;text-align: right" >
  		<img title="Back" onMouseOut="this.src='../../themes/<?php echo $styleSheet;?>/pictures/btn_back.gif';"
  			 onMouseOver="this.src='../../themes/<?php echo $styleSheet;?>/pictures/btn_back_02.gif';"
  			 src="../../themes/<?php echo $styleSheet;?>/pictures/btn_back.gif" onClick="goBack();">
	</div>
	<br>
	</div>
	</center>
	<script type="text/javascript">
        	if (document.getElementById && document.createElement) {
   	 			initOctopus();
			}
 	 </script>
</body>
</html>
